import java.util.Scanner;

/**
 * @author: gao
 * @create-date: 2025/4/10 14:31
 */

class ListNode{
    int val;
    ListNode next;

    public ListNode() {
    }

    public ListNode(int val) {
        this.val = val;
    }

    public ListNode(int val, ListNode next) {
        this.val = val;
        this.next = next;
    }
}

public class Solution {
    public ListNode mergeTwoLists(ListNode list1, ListNode list2){
        if(list1 == null) return list2;
        if(list2 == null) return list1;

        if(list1.val >= list2.val){
            list2.next = mergeTwoLists(list1,list2.next);
            return list2;
        }else {
            list1.next =  mergeTwoLists(list1.next,list2);
            return list1;
        }
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()){
            int len1 = in.nextInt();
            ListNode list1 = null;
            ListNode cur1 = null;
            for (int i = 0; i < len1; i++) {
                int val = in.nextInt();
                ListNode newNode = new ListNode(val);
                if (list1 == null) {
                    list1 = newNode;
                    cur1 = newNode;
                } else {
                    cur1.next = newNode;
                    cur1 = newNode;
                }
            }

            int len2 = in.nextInt();
            ListNode list2 = null;
            ListNode cur2 = null;
            for (int i = 0; i < len2; i++) {
                int val = in.nextInt();
                ListNode newNode = new ListNode(val);
                if (list2 == null) {
                    list2 = newNode;
                    cur2 = newNode;
                } else {
                    cur2.next = newNode;
                    cur2 = newNode;
                }
            }

            Solution solution = new Solution();
            ListNode NewList = solution.mergeTwoLists(list1,list2);
            ListNode cur = NewList;
            while (cur != null){
                System.out.print(cur.val + " ");
                cur = cur.next;
            }
        }
    }
}